package com.xiaoxu.privatechat.service.common;

import com.xiaoxu.privatechat.dao.common.MsgLogDao;
import com.xiaoxu.privatechat.entity.common.MsgLog;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xiaoxu
 * @description 消息记录管理service
 * @date 2023/2/13
 */
@Service
public class MsgLogService {

    @Resource
    private MsgLogDao msgLogDao;

    /**
     * @param id 日志id
     * @return MsgLog
     * @description 根据id查询
     */
    public MsgLog find(Long id) {
        return msgLogDao.find(id);
    }


    /**
     * @param msgLog 日志信息
     * @return MsgLog
     * @description 添加/编辑操作
     */
    public MsgLog save(MsgLog msgLog) {
        return msgLogDao.save(msgLog);
    }

    /**
     * @param accountId 账户信息
     * @param status    状态
     * @return List<MsgLog>
     * @description 获取指定用户的指定状态消息
     */
    public List<MsgLog> findByAccountIdAndStatus(Long accountId, int status) {
        return msgLogDao.findByAccountIdAndStatus(accountId, status);
    }

    /**
     * @param msgContentId 内容信息id
     * @return List<MsgLog>
     * @description 根据消息内容查询关联记录
     */
    public List<MsgLog> findByMsgContentId(Long msgContentId) {
        return msgLogDao.findByMsgContentId(msgContentId);
    }

    /**
     * @return long
     * @description 返回总数
     */
    public long total() {
        return msgLogDao.count();
    }
}
